#include <iostream>
#include <string>
#include <string.h>
using namespace std;

class Test
{
public:
    Test(const char *p)
    {
        if(p != nullptr)
        {
            int len = strlen(p);
            this->m_p = new char[len + 1];
            memcpy(m_p, p, len);
        }
        else
        {
            p = nullptr;
        }
    }

    Test(const Test &other)
    {
        cout << "Test copy" << endl;    
        
        
        if(other.m_p != nullptr)
        {
            int len = strlen(other.m_p);
            this->m_p = new char[len + 1];//
            memcpy(m_p, other.m_p, len);//  m_p = other.m_p;  other.m_p = nullptr;
        }
        else
        {
            m_p = nullptr;
        }
        
    }


    Test(Test &&other)
    {
        cout << "Test Move copy" << endl;
        m_p = other.m_p;
        other.m_p = nullptr;
    }

    ~Test()
    {
        if(m_p != nullptr)
        {
            delete [] m_p;
        }

        m_p = nullptr;
    }
    char *m_p;
};


int main(int argc, char **argv)
{
    Test t("hello world");

    Test t1 = t;

    Test t2 = std::move(Test("kk"));
    Test t3 = std::move(t);
    
    return 0;
}